import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 流程表单分类
const api = {
	update: '/v1/form-category/update', // id修改信息
	page: '/v1/form-category/page', // 分页列表
	listTree: '/v1/form-category/list-tree', // 树列表
	delete: '/v1/form-category/delete', // 根据ids删除
	create: '/v1/form-category/create', // 创建
	listAll: '/v1/form-category/list-all', // 列表 (所有部门)
	getOneDetail: '/v1/form-category/get' // 查询id信息
}

function formCategoryPageApi(data: any): AxiosPromise {
	return request({
		url: api.page,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

function formCategoryAddOrEditSaveApi(data: any): AxiosPromise {
	return request({
		url: data.id ? api.update : api.create,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

function formCategoryListTreeApi(data: any): AxiosPromise {
	return request({
		url: api.listTree,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

function formCategoryDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data,
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

function formCategoryDetailApi(): AxiosPromise {
	return request({
		url: api.getOneDetail,
		method: 'get',
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

function formCategoryListAllApi(): AxiosPromise {
	return request({
		url: api.listAll,
		method: 'get',
		headers: {
			'Menu-code': 'FORM_CATEGORY'
		}
	})
}

export default {
	formCategoryPageApi,
	formCategoryAddOrEditSaveApi,
	formCategoryDeleteApi,
	formCategoryDetailApi,
	formCategoryListAllApi,
	formCategoryListTreeApi
}
